﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Library.Models;

namespace Library.TwiCommunication
{
    class TwiCommunicatorMock : ITwiCommunicator
    {
        public TwiDevice ReadDevice(TwiDevice device)
        {
            if (device.GetType() == typeof(InDevice)) return ReadDevice(device as InDevice);
            if (device.GetType() == typeof(OutDevice)) return ReadDevice(device as OutDevice);
            if (device.GetType() == typeof(InOutDevice)) return ReadDevice(device as InOutDevice);
            if (device.GetType() == typeof(TermDevice)) return ReadDevice(device as TermDevice);
            return device;
        }

        public InDevice ReadDevice(InDevice device)
        {
            return device;
        }

        public OutDevice ReadDevice(OutDevice device)
        {
            return device;
        }

        public InOutDevice ReadDevice(InOutDevice device)
        {
            return device;
        }

        public TermDevice ReadDevice(TermDevice device)
        {
            device.Temp = 3.14d;
            return device;
        }

        public void WriteDevice(TwiDevice device)
        {
            if (device.GetType() == typeof(OutDevice)) WriteDevice(device as OutDevice);
            if (device.GetType() == typeof(InOutDevice)) WriteDevice(device as InOutDevice);
        }

        public void WriteDevice(OutDevice device) { }

        public void WriteDevice(InOutDevice device) { }
    }
}
